package com.naton.common.ui

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.naton.common.utils.ToastUtils
import com.wega.library.loadingDialog.LoadingDialog

/**
 * activity的基类
 */
open class BaseActivity<VB : ViewBinding>() : BaseVBActivity<VB>() , ViewBehavior{

    private var mLoadingDialog : LoadingDialog? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mLoadingDialog = LoadingDialog(this)
        //入栈
        ActivityStackManager.getManager().push(this)

    }

    /**
     * 显示吐司
     */
    override fun showToast(msg: String) {
        ToastUtils.show(msg)
    }

    /**
     * 显示加载条
     */
    override fun showProgress() {
        if (mLoadingDialog != null)
            mLoadingDialog?.loading("正在加载...")
    }

    override fun hideProgress() {
        if (mLoadingDialog != null)
            mLoadingDialog?.cancel()
    }

    override fun onDestroy() {
        super.onDestroy()
        //移除
        ActivityStackManager.getManager().remove(this)
    }
}